/* eslint-disable no-undef */
import Vue from 'vue';
// window['_Province'] = []
// window['_City'] = []

// window.Dictionary = {}

// window['Dictionary']={
//     'upChannelNo':[],
//     'Province':[],
//     'City':[],
//     'Carrier':[],
//     'ServiceTypeInfo':[],
//     'BrandInfo':[], 
// }

Vue.filter('Dictionary', (type, value) => { 
    let result = '--';
    window[value.value].forEach(element => {
        if (element[value.sysDicStatus] == type) {
            result = element[value.result]
            return;
        }
    });
    return result;
})




Vue.filter('_Province', (type, value) => {
    let result = '--';
    window['_Province'].forEach(element => {
        if (element.provinceNo == type) {
            result = element.provinceName
            return;
        }
    });
    return result;
})
Vue.filter('_City', (type, value) => {
    let result = '';
    window['_City'].forEach(element => {
        if (element.cityNo == type) {
            result = element.cityName
            return;
        }
    });
    if (!result) {
        window['_City'].forEach(element => {
            if (element.essCityCode == type) {
                result = element.cityName
                return;
            }
        });
    }
    return result;
})

Vue.filter('dateTime', function (date, type) {
    if (date != null && date != "") {
        let yer,
            month,
            day,
            HH,
            mm,
            ss;
        let time = new Date(date),
            timeDate;
        yer = time.getFullYear();
        month = time.getMonth() + 1;
        day = time.getDate();
        HH = time.getHours(); //获取系统时，
        mm = time.getMinutes(); //分
        ss = time.getSeconds(); //秒

        month = (month < 10) ? ('0' + month) : month;
        day = (day < 10) ? ('0' + day) : day;
        HH = (HH < 10) ? ('0' + HH) : HH;
        mm = (mm < 10) ? ('0' + mm) : mm;
        ss = (ss < 10) ? ('0' + ss) : ss;

        switch (type) {
            case 'yyyy':
                timeDate = String(yer);
                break;
            case 'yyyy-MM':
                timeDate = yer + '-' + month;
                break;
            case 'yyyy-MM-dd':
                timeDate = yer + '-' + month + '-' + day;
                break;
            case 'yyyy/MM/dd':
                timeDate = yer + '/' + month + '/' + day;
                break;
            case 'yyyy-MM-dd HH:mm:ss':
                timeDate = yer + '-' + month + '-' + day + ' ' + HH + ':' + mm + ':' + ss;
                break;
            case 'HH:mm:ss':
                timeDate = HH + ':' + mm + ':' + ss;
                break;
            case 'MM':
                timeDate = String(month);
                break;
            default:
                timeDate = yer + '-' + month + '-' + day;
                break;
        }
        return timeDate
    } else {
        return ''
    }
})